-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSP: Hide wrapper span with class instead of style attribute #581
base: master
Are you sure you want to change the base?
Conversation
CSP nonces need to be added to any elements with a style attribute
With this patch, I'm still seeing the csp errors in console of Safari, Firefox, Chrome. I believe for |
Oh, so there's no way to use inline style attributes with nonces? Reference: https://content-security-policy.com/examples/allow-inline-style/ (the section about inline style attribute). |
I'm vendoring this repo and patching it :-/ instead of explaining "unsafe-hashes" to whom it may concern 😆 |
I realised that perhaps the function can omit the style attribute if you use a nonce, so you will have to use the class to hide the span. I'm reopening this and then I'll push these changes. Edit: I still think for most users is easier to add unsafe-hashes rather than introducing a new stylesheet to the CSP, especially if you only use elm-css. |
@choonkeat
I saw that there is no nonce for the |
|> styleToDeclaration (getCssTemplate [ Css.display Css.none ]) styleWrapperClass nice solution!
yes, I have a quick patch for local use for now type Nonce
= Nonce String
noncedGlobal : Nonce -> List Snippet -> Html.Styled.Html msg
noncedGlobal (Nonce nonce) snippets =
snippets
|> Preprocess.stylesheet
|> Resolve.compile
|> VirtualDom.text
|> List.singleton
|> VirtualDom.node "style" [ VirtualDom.attribute "nonce" nonce ]
|> List.singleton
|> VirtualDom.node "span"
[ VirtualDom.attribute "class" "elm-css-style-wrapper"
]
|> VirtualDom.Styled.unstyledNode not particularly joyful to have 2 |
CSP nonces need to be added to any elements with a style attribute
This PR fixes the issue found in #570 (comment)